<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Pro;
use App\Att;

class CheckController extends Controller
{

public function prolist(){
	$pros =Pro::orderBy('pid','desc')->get();
	return view('auth.prolist',['pros'=>$pros]);
}

	//取出审核项目
public function check($pid){
	$pro = Pro::find($pid);
	$att= Att::where('pid',$pid)->first();
	if(empty($pro)){
		return redirect('/prolist');
	}
	return view('auth.shenhe',['pro'=>$pro,'att'=>$att]);
 }

	public function checkPost(Request $req , $pid){
			$pro = Pro::find($pid);
			$att = Att::where('pid' , $pid)->first();
		if(empty($pro)) {
			return redirect('/prolist');
		} 
			$pro->title = $req->title;
			$pro->hrange = $req->hrange;
			$pro->rate = $req->rate; // 百分比
			$pro->status = $req->status;
			$rs = $pro->save();

			$att->realname = $req->realname;
			$att->gender = $req->gender;
			$att->udesc = $req->udesc;
			$att->title = $req->title;
			$att->jobcity=$req->jobcity;
		if( $rs && $att->save() ) {
			return redirect('/prolist');
		} else {
			return 'error';
		}
	}
}
